package avicit.bdp.dms.tdm.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.LogField;
import avicit.platform6.core.properties.PlatformConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;

@ApiModel(value = "BdpAssetMountDataServiceDTO", description = "资产挂载数据服务")
@Table(name = "bdp_asset_mount_data_service")
public class BdpAssetMountDataServiceDTO extends BaseDTO {

  private static final long serialVersionUID = 1L;

  /** 主键ID */
  @LogField
  @ApiModelProperty(value = "主键")
  @FieldRemark(column = "id", field = "id", name = "主键")
  @Column(name = "id")
  @avicit.platform6.core.annotation.log.Id
  @javax.persistence.Id
  private String id;

  /** 数据资产id */
  @LogField
  @ApiModelProperty(value = "数据资产id", name = "assetId")
  @FieldRemark(column = "asset_id", field = "assetId", name = "数据资产id")
  private String assetId;

  /** 资源类型[1-数据服务/2-文档/3-报表分析/4-模型] */
  @LogField
  @ApiModelProperty(value = "资源类型[1-数据服务/2-文档/3-报表分析/4-模型]", name = "assetType")
  @FieldRemark(column = "asset_type", field = "assetType", name = "资源类型[1-数据服务/2-文档/3-报表分析/4-模型]")
  private String assetType;

  /** 数据源id */
  @LogField
  @ApiModelProperty(value = "数据源id", name = "datasourceId")
  @FieldRemark(column = "datasource_id", field = "datasourceId", name = "数据源id")
  private String datasourceId;

  /** 方式[1-表/2-SQL] */
  @LogField
  @ApiModelProperty(value = "方式[1-表/2-SQL]", name = "mountType")
  @FieldRemark(column = "mount_type", field = "mountType", name = "方式[1-表/2-SQL]")
  private String mountType;

  /** 数据表 */
  @ApiModelProperty(value = "数据表", name = "tableName")
  @FieldRemark(column = "table_name", field = "tableName", name = "数据表")
  private String tableName;

  /** 返回字段 */
  @ApiModelProperty(value = "返回字段", name = "columnInfo")
  @FieldRemark(column = "column_info", field = "columnInfo", name = "返回字段")
  private String columnInfo;

  /** SQL脚本 */
  @ApiModelProperty(value = "SQL脚本", name = "sqlScript")
  @FieldRemark(column = "sql_script", field = "sqlScript", name = "SQL脚本")
  private String sqlScript;

  /** 开放服务类型[1-数据查询/2-数据推送/3-API接口/4-下载/5-模型/6-报表] */
  @LogField
  @ApiModelProperty(
      value = "开放服务类型[1-数据查询/2-数据推送/3-API接口/4-下载/5-模型/6-报表]",
      name = "openServiceType")
  @FieldRemark(
      column = "open_service_type",
      field = "openServiceType",
      name = "开放服务类型[1-数据查询/2-数据推送/3-API接口/4-下载/5-模型/6-报表]")
  private String openServiceType;

  /** 增量更新方式[0-无/1最大值增量/2主键+日期增量] */
  @ApiModelProperty(value = "增量更新方式[0-无/1最大值增量/2主键+日期增量]", name = "incrementalUpdateMethod")
  @FieldRemark(
      column = "incremental_update_method",
      field = "incrementalUpdateMethod",
      name = "增量更新方式[0-无/1最大值增量/2主键+日期增量]")
  private String incrementalUpdateMethod;

  /** 增量更新最大值增量字段 */
  @ApiModelProperty(value = "增量更新最大值增量字段", name = "incrementalMaxValueFiled")
  @FieldRemark(
      column = "incremental_max_value_filed",
      field = "incrementalMaxValueFiled",
      name = "增量更新最大值增量字段")
  private String incrementalMaxValueFiled;

  /** 增量更新主键字段 */
  @ApiModelProperty(value = "增量更新主键字段", name = "incrementalPrimaryFiled")
  @FieldRemark(
      column = "incremental_primary_filed",
      field = "incrementalPrimaryFiled",
      name = "增量更新主键字段")
  private String incrementalPrimaryFiled;

  /** 增量更新日期字段 */
  @ApiModelProperty(value = "增量更新日期字段", name = "incrementalDateFiled")
  @FieldRemark(column = "incremental_date_filed", field = "incrementalDateFiled", name = "增量更新日期字段")
  private String incrementalDateFiled;

  /** API接口 */
  @ApiModelProperty(value = "API接口", name = "apiAddress")
  @FieldRemark(column = "api_address", field = "apiAddress", name = "API接口")
  private String apiAddress;

  /** 请求方式：get,post */
  @ApiModelProperty(value = "请求方式：get,post", name = "requestMethod")
  @FieldRemark(column = "request_method", field = "requestMethod", name = "请求方式：get,post")
  private String requestMethod;

  /** 缓存设置[1-开启/0-关闭] */
  @ApiModelProperty(value = "缓存设置[1-开启/0-关闭]", name = "cache")
  @FieldRemark(column = "cache", field = "cache", name = "缓存设置[1-开启/0-关闭]")
  private String cache;

  /** 缓存时长(秒) */
  @ApiModelProperty(value = "缓存时长(秒)", name = "cacheTimeout")
  @FieldRemark(column = "cache_timeout", field = "cacheTimeout", name = "缓存时长(秒)")
  private Integer cacheTimeout;

  /** 数据空间id */
  @ApiModelProperty(value = "数据空间id", name = "projectId")
  @FieldRemark(column = "project_id", field = "projectId", name = "数据空间id")
  private String projectId;

  @Transient
  private String datasourceName;
  
  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getAssetId() {
    return assetId;
  }

  public void setAssetId(String assetId) {
    this.assetId = assetId;
  }

  public String getAssetType() {
    return assetType;
  }

  public void setAssetType(String assetType) {
    this.assetType = assetType;
  }

  public String getDatasourceId() {
    return datasourceId;
  }

  public void setDatasourceId(String datasourceId) {
    this.datasourceId = datasourceId;
  }

  public String getMountType() {
    return mountType;
  }

  public void setMountType(String mountType) {
    this.mountType = mountType;
  }

  public String getTableName() {
    return tableName;
  }

  public void setTableName(String tableName) {
    this.tableName = tableName;
  }

  public String getColumnInfo() {
    return columnInfo;
  }

  public void setColumnInfo(String columnInfo) {
    this.columnInfo = columnInfo;
  }

  public String getSqlScript() {
    return sqlScript;
  }

  public void setSqlScript(String sqlScript) {
    this.sqlScript = sqlScript;
  }

  public String getOpenServiceType() {
    return openServiceType;
  }

  public void setOpenServiceType(String openServiceType) {
    this.openServiceType = openServiceType;
  }

  public String getIncrementalUpdateMethod() {
    return incrementalUpdateMethod;
  }

  public void setIncrementalUpdateMethod(String incrementalUpdateMethod) {
    this.incrementalUpdateMethod = incrementalUpdateMethod;
  }

  public String getIncrementalMaxValueFiled() {
    return incrementalMaxValueFiled;
  }

  public void setIncrementalMaxValueFiled(String incrementalMaxValueFiled) {
    this.incrementalMaxValueFiled = incrementalMaxValueFiled;
  }

  public String getIncrementalPrimaryFiled() {
    return incrementalPrimaryFiled;
  }

  public void setIncrementalPrimaryFiled(String incrementalPrimaryFiled) {
    this.incrementalPrimaryFiled = incrementalPrimaryFiled;
  }

  public String getIncrementalDateFiled() {
    return incrementalDateFiled;
  }

  public void setIncrementalDateFiled(String incrementalDateFiled) {
    this.incrementalDateFiled = incrementalDateFiled;
  }

  public String getApiAddress() {
    return apiAddress;
  }

  public void setApiAddress(String apiAddress) {
    this.apiAddress = apiAddress;
  }

  public String getRequestMethod() {
    return requestMethod;
  }

  public void setRequestMethod(String requestMethod) {
    this.requestMethod = requestMethod;
  }

  public String getCache() {
    return cache;
  }

  public void setCache(String cache) {
    this.cache = cache;
  }

  public Integer getCacheTimeout() {
    return cacheTimeout;
  }

  public void setCacheTimeout(Integer cacheTimeout) {
    this.cacheTimeout = cacheTimeout;
  }

  public String getDatasourceName() {
    return datasourceName;
  }


  public void setDatasourceName(String datasourceName) {
    this.datasourceName = datasourceName;
  }

  public String getProjectId() {
    return projectId;
  }

  public void setProjectId(String projectId) {
    this.projectId = projectId;
  }

  public String getLogFormName() {
    if (StringUtils.isEmpty(super.logFormName)) {
      return "资产-数据服务";
    } else {
      return super.logFormName;
    }
  }

  public String getLogTitle() {
    if (StringUtils.isEmpty(super.logTitle)) {
      return "资产-数据服务";
    } else {
      return super.logTitle;
    }
  }

  public PlatformConstant.LogType getLogType() {
    if (super.logType == null) {
      return PlatformConstant.LogType.module_operate;
    } else {
      return super.logType;
    }
  }
}
